package com.tiny.model;

import java.util.List;

import com.jfinal.plugin.activerecord.Model;

public class Menu extends Model<Menu>{

	private static final long serialVersionUID = 5721481570867001052L;

	public static final Menu dao = new Menu();
	
	public Integer getId() {
		return this.getInt("id");
	}
	
	public Integer getParentId(){
		return this.getInt("parent_id");
	}
	
	public String getName(){
		return this.getStr("name");
	}
	
	public String getUrl(){
		return this.getStr("url");
	}
	
	public Integer getOrder(){
		return this.getInt("order");
	}
			
	
	public List<Menu> getAllMenu(){
		return Menu.dao.find(" select * from menu ");
	}
	
	public Menu get(List<Menu> menus, int id) {
        for(Menu menu:menus){
            if(menu.getId().intValue()==id){
                return menu;
            }
        }
        return null;
    }
	
}
